function GetQueryString(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}
$(function () {
    var browser = {
        versions: function () {
            var u = navigator.userAgent, app = navigator.appVersion;
            return {         //移动终端浏览器版本信息
                trident: u.indexOf('Trident') > -1, //IE内核
                presto: u.indexOf('Presto') > -1, //opera内核
                webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
                iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
                iPad: u.indexOf('iPad') > -1, //是否iPad
                webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
                MQQBrowser: u.indexOf('MQQBrowser') !== -1
            };
        }(),
        language: (navigator.browserLanguage || navigator.language).toLowerCase()
    };

    var localUrl="";
    if(GetQueryString('jumpType')==1){
        localUrl="ixinghui://ixinghui.share.com?jumpType=1&type="+GetQueryString('type')+"&topicId="+GetQueryString('topicId');
    }else if(GetQueryString('jumpType')==9){
        localUrl="ixinghui://ixinghui.share.com?jumpType=9&articleId="+GetQueryString('articleId');
    }else if(GetQueryString('jumpType')==4){
        localUrl="ixinghui://ixinghui.share.com?jumpType=4&productId="+GetQueryString('productId');
    }
    if (browser.versions.ios) {
        //直接打开app
        window.location.href=localUrl;
    }
    if(browser.versions.android){
        window.location.href = localUrl;
    }
    //直接下载
    $(".downloadApp_btn").on("click", function () {
        if (browser.versions.ios) {
            window.open("https://a.app.qq.com/o/simple.jsp?pkgname=com.yunxuan.ixinghui")
        } else if (browser.versions.android) {
            window.open("https://a.app.qq.com/o/simple.jsp?pkgname=com.yunxuan.ixinghui")
        } else {
            window.open("https://android.myapp.com/myapp/detail.htm?apkName=com.yunxuan.ixinghui")
        }
    });

});